<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="../org/angular.min.js"></script>
    <script src="../org/jquery.min.js"></script>
</head>

<body>

<div ng-app="hd">
    <div ng-controller="ctrl">
        <table border="1" width="600px">
            <tr>
                <td>网站名称</td>
                <td>网址</td>
            </tr>
            <tr ng-repeat="v in data">
                <td>{{v.name}}</td>
                <td>{{v.url}}</td>
            </tr>
        </table>
    </div>
</div>

<script>
    function callback($http) {
        return $http({method: 'get', url: '1.php'}).then(function (response) {
            return response.data;
        })
    }

    var m = angular.module('hd', []);
    //使用service定义服务
    m.service('videoServer', ['$http', function ($http) {
        this.get = function () {
            return $http({method: 'get', url: '1.php'}).then(function (response) {
                return response.data;
            });
        }
    }]);
    
    //林外一种写法
    m.service('videoServer1', callback);



    m.controller('ctrl', ['$scope', 'videoServer1', function ($scope, videoServer1) {
        videoServer1.get().then(function (data) {
            $scope.data = data;
        });
    }]);

</script>

</body>

</html>